package com.tledu.spring.service.impl;

import com.tledu.spring.dao.IUserDao;
import com.tledu.spring.dao.impl.UserDaoImpl;
import com.tledu.spring.model.User;
import com.tledu.spring.service.IUserService;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author cyrus
 */
@NoArgsConstructor
public class UserServiceImpl implements IUserService {
    /**
     * 交给容器去进行管理，由spring 容器来注入进来这个依赖
     */
    @Setter
    private IUserDao userDao;

    @Setter
    private List<String> lists;
    @Setter
    private Set<String> sets;
    @Setter
    private Map<String, String> maps;


    public void initBean() {
        // 希望在容器初始化的时候，做一些
        System.out.println("初始化Userservice实例，init");
        // 实例已经初始化完成了
        System.out.println(sets);
    }

    public void beanDestroy() {
        System.out.println("容器被销毁，destroy");
    }

    public UserServiceImpl(IUserDao userDao) {
        System.out.println("用户服务初始化了");
        this.userDao = userDao;
    }

    @Override
    public User select(int id) {
        System.out.println(lists);
        System.out.println(sets);
        System.out.println(maps);
        return userDao.selectById(id);
    }
}
